package com.liu.util;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import com.liu.behaviortracker.Common;

import de.robv.android.xposed.XposedBridge;

public class TrackerLoger {
	
	public static void log(String tag, String content, String type, boolean copy2xposedLog) {
		
		String logPath = Common.LOGPATH + type + ".log";
		File logFile = new File(logPath);
		if(!logFile.exists()) {
			try {
				logFile.createNewFile();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		try {
			FileWriter writer = new FileWriter(logFile, true);
			
			writer.append(Timer.getTime() + tag + content + "\n");
			
			writer.flush();
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		if(copy2xposedLog)
			XposedBridge.log(Timer.getTime() + tag + content);
	}

}
